package com.uglyboys.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.uglyboys.R;
import com.uglyboys.model.Brother;
public class BrotherArrayAdapter extends ArrayAdapter<Brother>{
	private final Context context;
	private final List<Brother> values;
	public int count;
	
	public List<Brother> getValues() {
		return values;
	}
	
	public Context getContext() {
		return context;
	}


	public BrotherArrayAdapter(Context context, List<Brother> values) {
		super(context, R.layout.layout_brother, values);
		this.context = context;
		this.values = values;
		count = values.size();
	}
	
	
	@Override
	public void clear() {
		this.values.clear();
		super.clear();
	}
	
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.layout_brother, parent, false);
		
		ImageView imagem = (ImageView) rowView.findViewById(R.id.imagem);
		TextView txtNome = (TextView) rowView.findViewById(R.id.name);
		TextView txtIdadeEstado = (TextView) rowView.findViewById(R.id.years_old);
		TextView txtProfissao = (TextView) rowView.findViewById(R.id.profession);

		final Brother brother = values.get(position);
		
		imagem.setImageResource(brother.getIdImagem());
		txtNome.setText(brother.getNome());
		txtIdadeEstado.setText(brother.getIdadeEstado());
		txtProfissao.setText(brother.getProfissao());
		
		return rowView;
	}
	
	
	
	
	
	
}
